% TEST_ID: LANG-EXPAND-0128
% CATEGORY: language/string
% 测试 string 的复制

function test_string_strrep()
str = string('The quick brown fox');
newStr = strrep(str, string('quick'), string('sly'));
assert(isequal(newStr, 'The sly brown fox'));

str = string({'the quick brown fox';
        'and the lazy dog'});
newStr = strrep(str, 'the', 'a')
assert(isequal(newStr, string({'a quick brown fox'; 'and a lazy dog'})));

C1 = string({'Date Received: ___';
        'Date Accepted: ___'});
old = string({'___'; '___'});
new = string({'2016-09-06';
        '2016-10-11'});
C2 = strrep(C1,old,new);
assert(isequal(C2, string({'Date Received: 2016-09-06';'Date Accepted: 2016-10-11'})));

% 替换重复模式
repeats = string('abc 2 def 22 ghi 222 jkl 2222');
using_strrep = strrep(repeats, '22', '*');
assert(isequal(using_strrep, 'abc 2 def * ghi ** jkl ***'));
end